package org.dreamwork.jasmine2.web.client;

import java.util.regex.Matcher;

/**
 * Created by IntelliJ IDEA.
 * User: seth.yang
 * Date: 12-4-25
 * Time: 下午4:48
 */
class IEParser {
/*
Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)
group[1]=10.0
group[2]= NT
group[3]=6.2
group[4]= WOW64;
group[5]=6.0

Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; .NET4.0C; 360SE)
group[1]=7.0
group[2]= NT
group[3]=6.1
group[4]=null
group[5]=5.0

Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; .NET4.0C; .NET4.0E)
group[1]=8.0
group[2]= NT
group[3]=6.1
group[4]= WOW64;
group[5]=4.0

Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 1.1.4322; InfoPath.2; 360SE)
group[1]=8.0
group[2]= NT
group[3]=5.1
group[4]=null
group[5]=4.0
 */
    public static UserAgent parse (Matcher m) {
        UserAgent agent = new UserAgent (m.group (0));
        agent.setType (BrowserType.InternetExplorer);
        String s_browser_version = m.group (1);
        Version version = new Version (s_browser_version);
        agent.setVersion (version);

        OperationSystem os = OSParser.parseOS (m.group (0));
        agent.setOs (os);
        agent.setDevice (DeviceType.Computer);

        version = new Version (m.group (5));
        agent.setKernel (new RenderKernel (RenderkernelType.Trident, version));


        return agent;
    }
}